package controller;

import javax.websocket.EncodeException;
import javax.websocket.Encoder;
import javax.websocket.EndpointConfig;

/**
 * @author zhangyanqi
 * @since 1.0 2017/12/3
 */
public class ChattingRoomEncoder implements Encoder.Text<String> {


    public  ChattingRoomEncoder(){
        System.out.println(this.getClass().getName() + "#construct");
    }

    /**
     * Encode the given object into a String.
     *
     * @param object the object being encoded.
     * @return the encoded object as a string.
     */
    public String encode(String object) throws EncodeException {
        System.out.println("encode");
        return object;
    }

    /**
     * This method is called with the endpoint configuration object of the
     * endpoint this encoder is intended for when
     * it is about to be brought into service.
     *
     * @param config the endpoint configuration object when being brought into
     *               service
     */
    public void init(EndpointConfig config) {
        System.out.println(this.getClass().getName()+"#init");
    }

    /**
     * This method is called when the encoder is about to be removed
     * from service in order that any resources the encoder used may
     * be closed gracefully.
     */
    public void destroy() {
        System.out.println(this.getClass().getName() + "#destory");
    }
}
